/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.easyjava.app;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Locale;
import org.restlet.data.CharacterSet;
import org.restlet.data.MediaType;
import org.restlet.representation.InputRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

/**
 *
 * @author 朱雀
 */
public class ModelFromRescource extends ServerResource {

	@Get
	public InputRepresentation getStencilset() {
		InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("Model_zh_CN.json");
		InputRepresentation stencilsetResultRepresentation = new InputRepresentation(stencilsetStream);
		stencilsetResultRepresentation.setMediaType(MediaType.APPLICATION_JSON);
		stencilsetResultRepresentation.setCharacterSet(CharacterSet.UTF_8);
		return stencilsetResultRepresentation;
	}
//	@Get
//	public InputRepresentation getModelJson() {
//		String modelJsonFilename = "Model_" + Locale.getDefault().toString() + ".json";
//		InputStream modelJsonIS = this.getClass().getClassLoader().getResourceAsStream(modelJsonFilename);
//		BufferedReader br = new BufferedReader(new InputStreamReader(modelJsonIS));
//		int index = 0;
//		char inChar;
//		StringBuilder sb = new StringBuilder();
//		do {
//			try {
//				index = br.read();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//			inChar = (char) index;
//			if (index > -1) {
//				sb.append(inChar);
//			}
//		} while (index > -1);
//		JSONObject jsonObject=JSON.parseObject(sb.toString());
//		JSONArray nodeArray=jsonObject.getJSONArray("");
//	}
}
